<template>
    <Teleport to="body">
        <transition name="el-fade-in">
            <div class="comment-del-dialog" v-if="props.show">
                <div class="comment-del-dialog__mask" @click="onClose"></div>
                <div class="comment-del-dialog__content">
                    <img
                        class="icon-close"
                        :src="`${_oss_}images/icon-close-default.png`"
                        @click="onClose"
                    />

                    <div class="content">确认删除此项评论？</div>

                    <div class="btn-group">
                        <div class="btn-confirm" @click="onConfirm">确认</div>
                        <div class="btn-cancel" @click="onClose">取消</div>
                    </div>
                </div>
            </div>
        </transition>
    </Teleport>
</template>
<script setup>
const props = defineProps({
    show: {
        type: Boolean,
        default: false,
    },

    onConfirm: {
        type: Function,
        default: () => {},
    },
});

const emit = defineEmits(["update:show"]);

const onClose = () => {
    emit("update:show", false);
};

const onConfirm = () => {
    typeof props.onConfirm === "function" && props.onConfirm();
    onClose();
};
</script>
<style lang="scss" scoped>
.comment-del-dialog {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999;

    &__mask {
        position: relative;
        width: 100%;
        height: 100%;
        background-color: rgba($color: #000000, $alpha: 0.5);
    }

    &__content {
        position: absolute;
        top: 50%;
        left: 50%;

        width: 300px;
        height: 180px;
        background: #fff;
        transform: translate(-50%, -50%);
        border-radius: 10px;
    }

    .icon-close {
        position: absolute;
        top: 24px;
        right: 24px;
        width: 14px;
        height: 14px;
        cursor: pointer;
    }

    .content {
        text-align: center;
        font-size: 18px;
        margin-top: 65px;
        line-height: 1;
    }

    .btn-group {
        display: flex;
        justify-content: center;
        margin-top: 35px;
        user-select: none;

        .btn-confirm,
        .btn-cancel {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 100px;
            height: 36px;
            border-radius: 8px;
            cursor: pointer;
        }

        .btn-confirm {
            background-color: #5085fb;
            color: #fff;
        }

        .btn-cancel {
            border: 1px solid #dcdcdc;
            margin-left: 55px;
        }
    }
}
</style>
